PrefaceWebWork is a popular, easy-to-use MVC framework. For more information on the WebWork project, please visit the WebWork Project Home.
Distribution Download and Information ResourcesDownload Webwork DistributionYou can download the full WebWork distribution here. It contains the webwork.jar file as well as full documentation, sources, all required and optional dependent libraries,and examples. For more information on how to build WebWork from source or even from a clean CVS checkout, please refer to Building Webwork. Online Information and Project ResourcesThere are many online sources of information, support and project resources around. Here are links to help you find your way:
Distribution QuickstartOverviewThe distribution contains the following directory layout: dist/ docs/ lib/ src/ src/java/template/ webapps/ README.txt build.properties build.xml ivy.xml osbuild.xml pom.xml webwork-(VERSION).jar webwork-(VERSION).zip webwork-(VERSION)-src.jar
The docs directory contains the current Javadocs, the full user documentation including the document you are reading, and taglib documentation, as well as Clover, JUnit and dependency reports for the build. The dist directory contains WebWork files with different packaging:
The lib directory contains the required as well as optional Dependencies for Webwork, organized in subdirectories to represent different optional configurations: lib/ ajax bootstrap build cewolf default fileupload fileupload-cos fileupload-pell hibernate jasperreports jfree pico plexus portlet quickstart sitemesh source spring tiger tiles velocity xslt
Note that none of the optional packages are required to use Webwork. If you wish to use certain features such as JasperReports or Java 5 (Tiger) generics and annotation support, you must include the optional packages. Webwork also comes packaged with all the source files and templates for the JSP tags. Running demos with QuickStartWebWork provides a quick way to get started called QuickStart. QuickStart is essentially a combination of a few technologies, including the possibility to run web applications such as the provided examples out of the box with a stripped Jetty container. With that, running the demos is as easy as can be. You just need to call: java -jar webwork.jar quickstart:<application-name>
from the distribution's top directory, whereby <application-name> is to be replaced by one of the subdirectory names under webapps/, representing the various supplied demo applications. So if you want to start the shopping cart example, just type on your command line: java -jar webwork.jar quickstart:shopping-cart
After starting an example in that way, you will simply need to point your browser to http://localhost:8080/shopping-cart to view the results. The packaged examples are:
Read Quickstart documentation to learn more about how it works and how you can utilize it for your own applications. See below for a more detailed description of how the blank application helps you to easily create your own WebWork-based applications. Running Demos with Your Favorite Webcontainer
In order to deploy WebWork applications and demos to your favorite servlet container (also called web container) such as Apache Tomcat or Caucho Resin, you will need to build war files from within the webapps directory. You will find an ant build file there which will provide you with an easy way to accomplish that. To build a webapp war archive, simply run: ant build -Dwebapp=XXX
where XXX is the name of the webapp you want to build. After the build is finished, the fully-built war file can be found in the dist directory. You may deploy this file to any servlet container. For example: Your first WebWork ApplicationUsing the Blank TemplateAs said before, the webapps directory contains a blank web application template. It is meant to be left untouched, and instead, you will want to make a copy of it as a starting point for your own new WebWork-based application. Although you can perform such a copy operation yourself, there is a much easier way around: You will find an build.xml in the webapps directory, which if called with ant new will provide you with a fresh empty webapp with a name you will be prompted for. Setting up from ScratchStructure of your Web ApplicationThe following illustrates how your web application should be set up. Copy the webwork-(VERSION).jar, all the *.jar files in /lib/default and any necessary optional *.jar files in /lib/(optional configuration) to your webapp/lib directory. If you need to customize your own templates (how HTML is rendered from webwork UI tags), copy the /src/java/template directory into your webapp/ directory. Your webapp should look similar to this: /mywebapp/ /mywebapp/template/ /mywebapp/META-INF/ /mywebapp/WEB-INF/ /mywebapp/WEB-INF/classes/ /mywebapp/WEB-INF/lib/ /mywebapp/WEB-INF/lib/CORE&OPTIONAL *.jar /mywebapp/WEB-INF/web.xml
Minimum Set of Libraries and Config FilesThe following files are a minium requirement for your application.
The library files (*.jar) needs to be copied to your /mywebapp/WEB-INF/lib/ directory. If you need optional functionalities requiring dependencies on optional jars, they need to be copied to this directory, too.
web.xml:Create the following web.xml file in [webapp]/WEB-INF. If you already have a web.xml file, just add the content of the <web-app> tag below to your existing <web-app> tag. <?xml version="1.0"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>My WebWork Application</display-name> <filter> <filter-name>webwork</filter-name> <filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>webwork</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- As of 2.2, Spring is the preferred IoC container rather than XWork, so you'll have to include the spring jars if you want to use Spring's IoC capabilities in WebWork. (Thanks Hani for commenting) If you want to use deprecated integrated IoC container instead, you may want to omit the following listener configuration. --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- The following taglib directive would be needed if your servlet container would comply to Servlet Spec <= 2.2 <taglib> <taglib-uri>/webwork</taglib-uri> <taglib-location>/WEB-INF/lib/webwork.jar</taglib-location> </taglib> --> </web-app>
This registers FilterDispatcher to enable webwork functionality for your requests. The ContextLoaderListener will take care of setting up Spring as your IoC container for WebWork. The taglib entry will help you use Tags in your JSP pages. Read more: web.xml xwork.xml:Create the following file xwork.xml in [webapp]/WEB-INF/classes/. <!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1.1//EN" "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd"> <xwork> <!-- Include webwork defaults (from WebWork JAR). --> <include file="webwork-default.xml" /> <!-- Configuration for the default package. --> <package name="default" extends="webwork-default"> </package> </xwork>
For now, this xwork.xml does only two things:
Read more: xwork.xml Onward to the First lesson or return to the Webwork Start page |